<script setup lang="ts">
const props = defineProps({
  useName: {
    type: Boolean,
    default: false
  }
})
</script>

<template>
  <div class="content">
    <h1>Content</h1>

    <p>
      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
      tempor incididunt ut labore et dolore magna aliqua. Risus quis varius quam
      quisque id. Et ligula ullamcorper malesuada proin libero nunc consequat
      interdum varius. Elit ullamcorper dignissim cras tincidunt lobortis feugiat
      vivamus at augue.
    </p>

    <p>
      Dolor sed viverra ipsum nunc aliquet. Sed sed risus pretium quam vulputate
      dignissim. Tortor aliquam nulla facilisi cras. A erat nam at lectus urna
      duis convallis convallis. Nibh ipsum consequat nisl vel pretium lectus.
      Sagittis aliquam malesuada bibendum arcu vitae elementum. Malesuada bibendum
      arcu vitae elementum curabitur vitae nunc sed velit.
    </p>

    <div class="subject" :class="useName ? 'animationName' : 'animation'"></div>

    <p>
      Adipiscing enim eu turpis egestas pretium aenean pharetra magna ac. Arcu
      cursus vitae congue mauris rhoncus aenean vel. Sit amet cursus sit amet
      dictum. Augue neque gravida in fermentum et. Gravida rutrum quisque non
      tellus orci ac auctor augue mauris. Risus quis varius quam quisque id diam
      vel quam elementum. Nibh praesent tristique magna sit amet purus gravida
      quis. Duis ultricies lacus sed turpis tincidunt id aliquet. In egestas erat
      imperdiet sed euismod nisi. Eget egestas purus viverra accumsan in nisl nisi
      scelerisque. Netus et malesuada fames ac.
    </p>
  </div>
</template>

<style scoped lang="scss">
.subject {
  width: 300px;
  height: 200px;
  margin: 0 auto;
  background-color: deeppink;
}

.content {
  width: 75%;
  max-width: 800px;
  margin: 0 auto;
  height: 400px;
  overflow-y: auto;
}

p,
h1 {
  font-family: Arial, Helvetica, sans-serif;
}

h1 {
  font-size: 3rem;
}

p {
  font-size: 1.5rem;
  line-height: 1.5;
}
.animation {
  view-timeline-name: --subjectReveal;
  animation-timeline: --subjectReveal;

  animation-name: appear;
  animation-fill-mode: both;
  animation-duration: 1ms; /* Firefox requires this to apply the animation */
}
.animationName {
  animation-timeline: view();

  animation-name: appear;
  animation-fill-mode: both;
  animation-duration: 1ms; /* Firefox requires this to apply the animation */
}

@keyframes appear {
  from {
    opacity: 0;
    transform: scaleX(0);
  }

  to {
    opacity: 1;
    transform: scaleX(1);
  }
}
</style>